import 'package:enterprise_v6_app/app/components/custom_modele/custom_card.dart';
import 'package:enterprise_v6_app/app/components/custom_modele/custom_dropdown_selection.dart';
import 'package:enterprise_v6_app/app/components/custom_refresh.dart';
import 'package:enterprise_v6_app/app/core/core.dart';
import 'package:enterprise_v6_app/app/data/entities/application/standardiztion/standard_risk_inspect_notify_entity.dart';
import 'package:enterprise_v6_app/app/data/entities/application/standardiztion/standardization_entity.dart';
import 'package:enterprise_v6_app/app/modules/application/standardization/common.dart';
import 'package:enterprise_v6_app/app/modules/application/standardization/pages/risk/inspect/ctrl.dart';
import 'package:enterprise_v6_app/app/modules/application/standardization/pages/risk/inspect/model.dart';

/// 隐患排查治理
class StandardizationRiskInspectView extends StatelessWidget {
  StandardizationRiskInspectView({super.key});

  final ctrl = Get.put(StandardizationRiskInspectController());

  @override
  Widget build(BuildContext context) {
    return GetBuilder(
      init: ctrl,
      builder: (_) {
        return Column(
          children: [
            CustomDropdownSelection(
              text: ctrl.type.name,
              onCallBack: ctrl.showSelect,
              height: 37.w,
            ),
            AppGaps.vGap10,
            Expanded(child: _buildBody()),
          ],
        );
      },
    );
  }

  Widget _buildBody() {
    if (ctrl.type == StandardizationRiskInspectMenuType.rectification) {
      return CustomEasyRefreshList<StandardRiskInspectNotifyEntity>(
        key: ValueKey(ctrl.type),
        isShowSearch: true,
        dataLoad: ctrl.getNoti,
        itemBuilder: (entity, _) {
          return CustomCard(
            title: entity.reportTarget,
            divider: CustomCard.builtinDividerWithPadding,
            content: Column(
              children: [
                StandardizationCommon.buildItem('内容', entity.notificationContent),
                AppGaps.vGap10,
                StandardizationCommon.buildItem('通报时间', entity.reportDate),
              ],
            ),
          );
        },
      );
    }
    return CustomEasyRefreshList<StandardizationEntity>(
      key: ValueKey(ctrl.type),
      isShowSearch: true,
      dataLoad: ctrl.getPages,
      itemBuilder: StandardizationCommon.card,
    );
  }
}